<?php
session_start();
include "includes/comunes.php";
error_reporting(0);

if (isset($_REQUEST['query'])) {

	$query = $_REQUEST['query'];
	
	$sql = ins_sql("SELECT * FROM avisos WHERE avi_publicar=1 and avi_destacada = 1 and avi_region=".$_SESSION['region']." and and DATE_add(avi_fecha, INTERVAL ".CANDIAS." DAY) >= CURDATE()  and avi_titulo like '%{$query}%' or avi_aviso like '%{$query}%'");
	$array = array();
	
	while ($row = mysql_fetch_array($sql)) {
		$array[] = $row['avi_titulo'];
	}
	
	echo json_encode ($array); //Return the JSON Array

}

?>
